package demo2;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2023-09-27
 * Time: 18:25
 */
public class Test {
    public static void main(String[] args) {

    }
    public static void func(int a){
        try {
            System.out.println(10/a);
        }catch (ArithmeticException e){
            e.printStackTrace();
            System.out.println("a == 0");
        }

    }
    public static void main2(String[] args) {
        func(0);
    }
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try {
            int a = scanner.nextInt();
            int ret = 10 / a;
            System.out.println("ret的值为："+ret);
        }catch (NullPointerException e){
            System.out.println("  (NullPointerException)");
        }catch (ArithmeticException e){
            System.out.println("ArithmeticException ");
        }
        finally {
            System.out.println("finally执行了");
            System.out.println(" ");
            scanner.close();
        }

    }
}
